from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action
from core.support import set_cutscene, get_game

class Rooftop(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        
        # build list of actions
        self.add_action(Back)
        self.add_action(FarBack)
        self.add_action(Jump)
    
    # return description of room.
    def get_description(self):
        return "You made it safely to the rooftop.  There is no other way to get out of the building.  Put on your parachute and jump!"
    
    # return image of room
    def get_image(self):
        return 'rooftop.jpg'

class RooftopRoomHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return Rooftop

# define actions for this room

class Back(Action):
    def __init__(self):
        Action.__init__(self, "Back")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Return to The elevator"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'elevator'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    
class Jump(Action):
    def __init__(self):
        Action.__init__(self, "Jump")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Jump and pull your parachute cord"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'victory_screen'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"

    def is_enabled(self):
        
        game = get_game()
        
        player = game.get_player()
        if 'parachute' in player.inventory and 'Wyners' in player.inventory:
            return True
        else:        
            return False
        
class FarBack(Action):
    def __init__(self):
        Action.__init__(self, "FarBack")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Go get Wyners!! He's in danger!!"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'lubin_office'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"

    def is_enabled(self):
        
        game = get_game()
        
        player = game.get_player()
        if 'Wyners' in player.inventory:
            return False
        else:        
            return True